package org.rency.crawler.fetch.helper;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.rency.crawler.domain.FetchExtension;
import org.rency.crawler.domain.FetchRequest;
import org.rency.crawler.domain.FetchResponse;
import org.rency.crawler.domain.http.FetchHttpRequest;
import org.rency.crawler.domain.http.FetchHttpResponse;
import org.rency.crawler.domain.queue.FetchQueue;
import org.rency.crawler.domain.vo.DocDomain;
import org.rency.crawler.fetch.state.FetchStateCarrier;

/**
 * 描述: 抓取载体<br>
 * 最近修改时间:2017/11/20 17:43<br>
 *
 * @author CaiyuRen
 * @version V1.0
 * @since 2017/11/20 17:43
 */
public class FetchCarrier {

  private String                        logPrefix;

  private FetchRequest                  request;

  private FetchResponse                 response = FetchResponse.success();

  private FetchExtension                extension;

  private FetchHttpRequest              httpRequest;

  private FetchHttpResponse             httpResponse;

  private FetchStateCarrier             fetchState;

  /**
   * 抓取状态历史
   */
  private List<FetchStateCarrier>       fetchStateHistory;

  /**
   * 文档队列集合
   */
  private Collection<DocDomain>         docQueueCollcetion;

  /**
   * 抓取队列集合
   */
  private Collection<FetchQueue>        fetchQueueCollection;

  public FetchCarrier(FetchRequest request, FetchExtension extension){
    this.request = request;
    this.extension = extension;
  }

  public String getLogPrefix() {
    return logPrefix;
  }

  public void setLogPrefix(String logPrefix) {
    this.logPrefix = logPrefix;
  }

  public FetchRequest getRequest() {
    return request;
  }

  public void setRequest(FetchRequest request) {
    this.request = request;
  }

  public FetchResponse getResponse() {
    return response;
  }

  public void setResponse(FetchResponse response) {
    this.response = response;
  }

  public FetchExtension getExtension() {
    return extension;
  }

  public void setExtension(FetchExtension extension) {
    this.extension = extension;
  }

  public FetchHttpRequest getHttpRequest() {
    return httpRequest;
  }

  public void setHttpRequest(FetchHttpRequest httpRequest) {
    this.httpRequest = httpRequest;
  }

  public FetchHttpResponse getHttpResponse() {
    return httpResponse;
  }

  public void setHttpResponse(FetchHttpResponse httpResponse) {
    this.httpResponse = httpResponse;
  }

  public FetchStateCarrier getFetchState() {
    return fetchState;
  }

  public void setFetchState(FetchStateCarrier fetchState) {
    this.fetchState = fetchState;
  }

  public List<FetchStateCarrier> getFetchStateHistory() {
    return fetchStateHistory;
  }

  public void setFetchStateHistory(List<FetchStateCarrier> fetchStateHistory) {
    this.fetchStateHistory = fetchStateHistory;
  }

  public void addFetchStateHistory(FetchStateCarrier fetchState) {
    if(this.fetchStateHistory == null){
      this.fetchStateHistory = new ArrayList<FetchStateCarrier>();
    }
    this.fetchStateHistory.add(fetchState);
  }

  public Collection<DocDomain> getDocQueueCollcetion() {
    return docQueueCollcetion;
  }

  public void setDocQueueCollcetion(Collection<DocDomain> docQueueCollcetion) {
    this.docQueueCollcetion = docQueueCollcetion;
  }

  public Collection<FetchQueue> getFetchQueueCollection() {
    return fetchQueueCollection;
  }

  public void setFetchQueueCollection(Collection<FetchQueue> fetchQueueCollection) {
    this.fetchQueueCollection = fetchQueueCollection;
  }
}
